package projects.ufam.nodes.nodeImplementations;

import java.util.ArrayList;

import projects.defaultProject.models.mobilityModels.CorrelatedRandomWalk;
import projects.defaultProject.nodes.nodeImplementations.LocalizableNode;
import projects.ufam.CustomGlobal;
import sinalgo.configuration.Configuration;
import sinalgo.models.MobilityModel;
import sinalgo.nodes.Node;
import sinalgo.nodes.Position;
import sinalgo.runtime.Global;

public class Target {
	Position position, estimatedPosition;
	Position[] trace = new Position[CustomGlobal.simulationLength / 100];
	Position[] traceEstimation = new Position[CustomGlobal.simulationLength / 100];
	Position[] traceMeasurement = new Position[CustomGlobal.simulationLength / 100];
	boolean paintTrace = true;
	MobilityModel mm = null;

	public Target(Position p) {
		position = p;
		trace[(int) Global.currentTime % 100] = p;
		try {
			paintTrace = Configuration.getBooleanParameter("Target/paintTrace");
			Class clazz = Class.forName(CustomGlobal.mobilityModel);
			mm = (MobilityModel) clazz.getConstructor(null).newInstance(null);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updatePosition() {
		if (mm == null)
			return;
		Node n = new LocalizableNode();
		n.setPosition(this.position);
		position = mm.getNextPos(n);
		trace[(int) Global.currentTime / 100] = position;
	}

	public Position getPosition() {
		return position;
	}

	public void setPosition(Position position) {
		this.position = position;
	}

	public Position getEstimatedPosition() {
		return estimatedPosition;
	}

	public void setEstimatedPosition(Position estimatedPosition,
			Position measuredPosition, int timestamp) {
		this.estimatedPosition = estimatedPosition;
		traceEstimation[timestamp / 100] = estimatedPosition;
		traceMeasurement[timestamp / 100] = measuredPosition;
	}

	public Position[] getTrace() {
		return trace;
	}

	public void setTrace(Position[] trace) {
		this.trace = trace;
	}

	public Position[] getTraceEstimation() {
		return traceEstimation;
	}

	public void setTraceEstimation(Position[] traceEstimation) {
		this.traceEstimation = traceEstimation;
	}

	public Position[] getTraceMeasurement() {
		return traceMeasurement;
	}

	public void setTraceMeasurement(Position[] traceMeasurement) {
		this.traceMeasurement = traceMeasurement;
	}

}
